import Vue from 'vue'
import VueRouter from 'vue-router'
import  Layout  from "@/views/layout/Index.vue"
import  Login  from "@/views/login/Index.vue"
import  Home  from "@/views/layout/home/Home.vue"

const product = ()=>import('@/views/product/Index.vue')
const List = ()=>import('@/views/product/list/Index.vue')
const Category = ()=>import('@/views/product/category/Index.vue')
const Order = ()=>import('@/views/order/Index.vue')
const OrderList = ()=>import('@/views/order//list/Index.vue')
const OrderCollect = ()=>import('@/views/order/collect/Index.vue')
const Advert = ()=>import('@/views/advert/Index.vue')
const AdvertList = ()=>import('@/views/advert/list/Index.vue')
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component:Layout,
    children:[
      {
        path:'/',
        name:'home',
        component:Home
      },
      {
        path: '/product', // 产品管理
        name: 'product',
        component:product,
        children:[
          {
            path:'list', // 可以不配置前面的 /  (如果 /list 此时就作为根路径下的 / 并非 /product下的list。
            name:'list',
            component:List
          },
          {
            path:'category',
            name:'category',
            component:Category
          }
        ]
      },
      {
        path: '/order', // 订单管理
        name: 'order',
        component:Order,
        children:[
          {
            path:'order-list', // 可以不配置前面的 /  (如果 /list 此时就作为根路径下的 / 并非 /product下的list。
            name:'order-list',
            component:OrderList
          },
          {
            path:'order-collect',
            name:'order-collect',
            component:OrderCollect
          }
        ]
      },
      {
        path:'/advert',
        name:'advert',
        component:Advert,
        children:[
          {
            path:'advert-list', // 可以不配置前面的 /  (如果 /list 此时就作为根路径下的 / 并非 /product下的list。
            name:'advert-list',
            component:AdvertList
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component:Login,
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
